<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        
         
        
        // document.cookie="user=a123;expires="+date.toUTCString()+";path=/";
        // document.cookie="pwd=123;expires=";
        // document.cookie="phone=123355;expires="+date.toUTCString()+";path=/";
        // document.cookie="eamli=123@qq.com;expires="+date.toUTCString()+";path=/";

        function setCookie(name,val,day,path="/"){
            if(daye){
                var date=new Date();
                date.setDate(date.getDate()+day)//在原本的日期上加7天
                document.cookie=name+"="+val+";expires="+date.toUTCString()+";path="+path+";"
            }else{
                document.cookie=name+"="+val+";expires"+";path="+path+";"
            }
        }




        function getCookie(key){
            var cookie=document.cookie//获取cookie
            if(cookie){
                var dataList=cookie.split("; ")//将字符串拆分成数组
               for(var i=0;i<dataList.length;i++){
                   var item=dataList[i]//获取数组某项
                   var arr=item.split('=')//将获取的数组某项拆分成一个数组长度位2的数组
                   var name=arr[0]//获取某项cookie的键名
                   var val=arr[1]//获取某项cookie的键值
                   if(key===name){
                    return val
                   }
               }
            }
        }

        var temp=getCookie("user")
        console.log(temp)



    </script>
</body>
</html>